﻿<!--
	RegExpress
	
	Copyright (c) 2010, Daniel McGaughran
	
	Licensed under the Apache Licence, Version 2.0 (the "Licence");
	you may not use this file except in compliance with the Licence.
	You may obtain a copy of the License at
	
		http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the Licence is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the Licence for the specific language governing permissions and
	limitations under the Licence.
	
	-->

<UserControl x:Class="RegExpress.UI.HostControls.BasicMatch"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xrCt="clr-namespace:XrControls;assembly=XrControls" MinWidth="800">
    <Grid HorizontalAlignment="Center">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>
		
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition />
		</Grid.RowDefinitions>


		<TextBlock Grid.ColumnSpan="3" Style="{StaticResource LabelText}" Text="Expression" />
		
		<TextBox Grid.Row="1" Text="{Binding Mode=TwoWay, Path=RegExpression, UpdateSourceTrigger=PropertyChanged}" />
		<Expander Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Style="{DynamicResource PopupExpander}">
			<Expander.Header>
				<TextBlock Style="{StaticResource ButtonText}" Text="Options" />
			</Expander.Header>
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition />
					<RowDefinition />
					<RowDefinition />
					<RowDefinition />
				</Grid.RowDefinitions>

				<xrCt:ToggleSwitch Value="{Binding Path=IsCaseIgnored, Mode=TwoWay}">
					<TextBlock Style="{StaticResource SettingLabel}" Text="IgnoreCase" />
				</xrCt:ToggleSwitch>
				<xrCt:ToggleSwitch Grid.Row="1" Value="{Binding Path=IsWhitespaceIgnored, Mode=TwoWay}">
					<TextBlock Style="{StaticResource SettingLabel}" Text="IgnorePatternWhitespace" />
				</xrCt:ToggleSwitch>
				<xrCt:ToggleSwitch Grid.Row="2" Value="{Binding Path=IsNewlineMatchedByDot, Mode=TwoWay}">
					<TextBlock Style="{StaticResource SettingLabel}" Text="Singleline (Dot matches newline)" />
				</xrCt:ToggleSwitch>
				<xrCt:ToggleSwitch Grid.Row="3" Value="{Binding Path=IsMultiLine, Mode=TwoWay}">
					<TextBlock Style="{StaticResource SettingLabel}" Text="Multiline (^/$ operate per line)" />
				</xrCt:ToggleSwitch>
			</Grid>
		</Expander>
		
		<TextBlock Grid.Row="2" Grid.ColumnSpan="3" Style="{StaticResource LabelText}" MinWidth="400"
				Text="Input" />
				
		<TextBox Grid.Row="3" Text="{Binding Mode=TwoWay, Path=Input, UpdateSourceTrigger=PropertyChanged}" />
		
		<Button Grid.Row="3" Grid.Column="1" Command="{Binding PerformMatchCmd}"
                HorizontalAlignment="Center" VerticalAlignment="Center">
			<TextBlock Style="{StaticResource ButtonText}" Text="Has Match?" />
		</Button>
		
		<xrCt:ToggleSwitch Grid.Row="3" Grid.Column="2" IsReadOnly="True"
                HorizontalAlignment="Center" VerticalAlignment="Center"
                IsEnabled="{Binding HasResult}" Value="{Binding IsMatch}">
		</xrCt:ToggleSwitch>


		<TextBlock Grid.Row="4" Grid.ColumnSpan="3" Style="{StaticResource LabelText}" MinWidth="400"
				Text="Captured Groups" />

		<Border Grid.Row="5" Grid.ColumnSpan="3" Style="{StaticResource ListPanel}">
			<ItemsControl ItemsSource="{Binding Path=CapturedGroups}"
					Grid.IsSharedSizeScope="True" MinHeight="400">
				<ItemsControl.ItemTemplate>
					<DataTemplate>
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" SharedSizeGroup="GroupNum" />
								<ColumnDefinition Width="Auto" SharedSizeGroup="GroupName" />
								<ColumnDefinition />
							</Grid.ColumnDefinitions>


							<TextBlock Style="{StaticResource LabelText}"
									Text="{Binding Path=GroupNumber, StringFormat='[{0}]'}" />
							<TextBlock Style="{StaticResource LabelText}" Grid.Column="1" Margin="16,0"
									Text="{Binding Path=GroupName, StringFormat='[&quot;{0}&quot;]'}" />
							<TextBlock Grid.Column="2" Text="{Binding Value}" />
						</Grid>
					</DataTemplate>
				</ItemsControl.ItemTemplate>
			</ItemsControl>
		</Border>


	</Grid>
</UserControl>
